<!DOCTYPE html>



  


<html class="theme-next gemini use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="Hexo, NexT" />








  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.1.2" />






<meta name="description" content="javascript操作cookie的方法cookie存储数据限制 cookie的存储数据量限制：4kByte 4096个英文字符 cookie分类  会话cookie，数据存储在内存，浏览器关闭后就消失了 持久cookie，数据存储在浏览器指定的文件中，过期之后消失">
<meta property="og:type" content="article">
<meta property="og:title" content="cookie和session">
<meta property="og:url" content="http://yoursite.com/2017/09/20/cookie和sesson/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="javascript操作cookie的方法cookie存储数据限制 cookie的存储数据量限制：4kByte 4096个英文字符 cookie分类  会话cookie，数据存储在内存，浏览器关闭后就消失了 持久cookie，数据存储在浏览器指定的文件中，过期之后消失">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://yoursite.com/img/cookie%20and%20session.png">
<meta property="og:updated_time" content="2017-10-22T12:07:48.308Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="cookie和session">
<meta name="twitter:description" content="javascript操作cookie的方法cookie存储数据限制 cookie的存储数据量限制：4kByte 4096个英文字符 cookie分类  会话cookie，数据存储在内存，浏览器关闭后就消失了 持久cookie，数据存储在浏览器指定的文件中，过期之后消失">
<meta name="twitter:image" content="http://yoursite.com/img/cookie%20and%20session.png">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Gemini',
    version: '5.1.2',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/2017/09/20/cookie和sesson/"/>





  <title>cookie和session | Hexo</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Hexo</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/2017/09/20/cookie和sesson/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="shine-wl">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="http://dynamic-image.yesky.com/300x-/uploadImages/upload/20140912/upload/201409/wylnwjynkxijpg.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Hexo">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">cookie和session</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2017-09-20T14:52:18+08:00">
                2017-09-20
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="javascript操作cookie的方法"><a href="#javascript操作cookie的方法" class="headerlink" title="javascript操作cookie的方法"></a>javascript操作cookie的方法</h2><p><strong>cookie存储数据限制</strong></p>
<p>cookie的存储数据量限制：4kByte 4096个英文字符</p>
<p><strong>cookie分类</strong></p>
<ul>
<li>会话cookie，数据存储在内存，浏览器关闭后就消失了</li>
<li>持久cookie，数据存储在浏览器指定的文件中，过期之后消失</li>
</ul>
<a id="more"></a>
<p><strong>设置cookie</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">document.cookie=&apos;hello=nihao&apos;;</div></pre></td></tr></table></figure>
<p><strong>获取cookie</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">document.cookie; //获取的是字符串格式  &quot;hello=nihao&quot;</div></pre></td></tr></table></figure>
<p><strong>cookie 常用属性</strong></p>
<p>注意：设置属性是之间的<code>；</code> </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">expires 表示有效期</div><div class="line">path 表示路径 (在父路径下设置的cookie，子路径可以获取到，反之不可以)</div><div class="line"></div><div class="line">document.cookie=&apos;hello=hi; path=/; expires=时间&apos;</div></pre></td></tr></table></figure>
<p><strong>封装获取指定cookie的方法</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div></pre></td><td class="code"><pre><div class="line">//传递的参数，要获取的cookie</div><div class="line">function getCookie(key)&#123;</div><div class="line">	//获取所有的cookie</div><div class="line">    var all = document.cookie;</div><div class="line">    var result = null;</div><div class="line">    //判断cookie是否存在</div><div class="line">    if(all)&#123;</div><div class="line">      var kvs = all.split(&apos;; &apos;);</div><div class="line">      kvs.forEach(function(item)&#123;</div><div class="line">        var kv = item.split(&apos;=&apos;);</div><div class="line">        if(key == kv[0])&#123;</div><div class="line">          // 找到了对应的cookie</div><div class="line">          result = kv[1];</div><div class="line">          return false;// 终止forEach循环</div><div class="line">        &#125;</div><div class="line">      &#125;);</div><div class="line">    &#125;</div><div class="line">    return result;</div><div class="line">  &#125;</div></pre></td></tr></table></figure>
<p><strong>封装设置cookie的方法</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">//获取时间</div><div class="line">var date = new Date();</div><div class="line">//设置时间</div><div class="line">date.setDate(date.getDate() + 3);</div><div class="line"></div><div class="line">function setCookie(key,value,options)&#123;</div><div class="line">	//参数1 ：cookie名字</div><div class="line">	//参数2 ：cookie值</div><div class="line">   //参数3 ：属性</div><div class="line">   var cookie = key + &apos;=&apos; + value;</div><div class="line">   for(var key in options)&#123;</div><div class="line">     //遍历options拼接属性</div><div class="line">     cookie += &apos;; &apos; + key + &apos;=&apos; + options[key];</div><div class="line">   &#125;</div><div class="line">   //设置cookie</div><div class="line">   document.cookie = cookie;</div><div class="line"> &#125;</div><div class="line"></div><div class="line"> setCookie(&apos;hello&apos;,&apos;nihao&apos;,&#123;</div><div class="line">   expires : date.toGMTString(),//时间必须转换成这种格式才能设置cookie有效期</div><div class="line">   path : &apos;/&apos;</div><div class="line"> &#125;)</div></pre></td></tr></table></figure>
<h2 id="jquery操作cookie的方法"><a href="#jquery操作cookie的方法" class="headerlink" title="jquery操作cookie的方法"></a>jquery操作cookie的方法</h2><p>必做的一步引入文件：</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line">//引入jquery文件</div><div class="line">&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;</div><div class="line">//引入cookie文件依赖jquery</div><div class="line">&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.cookie.js&quot;&gt;&lt;/script&gt;</div></pre></td></tr></table></figure>
<p><strong>设置cookie</strong></p>
<p>注（路径问题）：在默认情况下，只有设置 cookie的网页才能读取该 cookie。如果想让一个页面读取另一个页面设 置的cookie，必须设置cookie的路径。cookie的路径用于设置能够读取 cookie的顶级目录。将这个路径设置为网站的根目录，可以让所有网页都能互相读取 cookie （一般不要这样设置，防止出现冲突） </p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">$.cookie(&apos;hello&apos;, &apos;nihao&apos;);</div><div class="line">$.cookie(&apos;hello&apos;, &apos;nihao&apos;,&#123;expires : 3,path : &apos;/&apos;&#125;);</div></pre></td></tr></table></figure>
<p><strong>获取cookie</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">$.cookie(&apos;hello&apos;); //等价于下面的 </div><div class="line">$.cookie().hello; //获取指定的cookie</div><div class="line">$.cookie();  //获取所有的cookie是对象方式  &#123;hello: &quot;nihao&quot;&#125;</div></pre></td></tr></table></figure>
<p><strong>删除cookie</strong></p>
<p>注：删除cookie实际上就是重新设置了cookie的有效期时间</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$.removeCookie(&apos;hello&apos;);</div></pre></td></tr></table></figure>
<h2 id="session"><a href="#session" class="headerlink" title="session"></a>session</h2><p><strong>在php中语法</strong></p>
<p>关于session（一般用户登录成功后会开启session、退出时会注销session）</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">// 开启session</div><div class="line">session_start();</div></pre></td></tr></table></figure>
<p>session开启之后会生成一个sessionid，然后以响应头的形式返回给浏览器，后续浏览器所有的请求都会以请求头的方式携带该sessionid</p>
<p><strong>后台模拟数据：</strong></p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div></pre></td><td class="code"><pre><div class="line">&lt;php?</div><div class="line"> // 开启session</div><div class="line"> $uname = $_GET[&apos;uname&apos;];</div><div class="line"> $pw = $_GET[&apos;pw&apos;];</div><div class="line"></div><div class="line"> if($uname == &apos;admin&apos; &amp;&amp; $pw == &apos;123&apos;)&#123;</div><div class="line">   // 登录成功开启session</div><div class="line">   session_start();</div><div class="line">//$_SESSION数组的使用类似于普通数组。不同的是。当页面结束后，$_SESSION的内容会被PHP解析器自动保存下来，同时在用户的浏览器留下一个cookie。下次用户访问时，使用该cookie继续会话。</div><div class="line"></div><div class="line">//存储session值，存储用户名</div><div class="line">   $_SESSION[&apos;uname&apos;] = $uname;</div><div class="line">   </div><div class="line">   $num = $_SESSION[&apos;num&apos;];</div><div class="line">   if($num)&#123;</div><div class="line">     $_SESSION[&apos;num&apos;] = $_SESSION[&apos;num&apos;] + 1;</div><div class="line">   &#125;else&#123;</div><div class="line">     $_SESSION[&apos;num&apos;] = 1;</div><div class="line">   &#125;</div><div class="line"></div><div class="line"> &#125;</div><div class="line">?&gt;</div></pre></td></tr></table></figure>
<h2 id="session与cookie的关系"><a href="#session与cookie的关系" class="headerlink" title="session与cookie的关系"></a>session与cookie的关系</h2><p><img src="/img/cookie and session.png" alt="Alt text"></p>
<p>session与cookie的关系：session可以依赖于cookie，也可以不依赖cookie（URL重写-把sessionid以参数的形式添加得到URL中）</p>
<blockquote>
<p>具体解释：</p>
</blockquote>
<p> 当程序需要为某个客户端的请求创建一个session时，服务器首先检查这个客户端的请求里是否已包含了一个session标识（称为session id），</p>
<p>如果已包含则说明以前已经为此客户端创建过session，服务器就按照session id把这个session检索出来使用（检索不到，会新建一个），如果</p>
<p>客户端请求不包含session id，则为此客户端创建一个session并且生成一个与此session相关联的session id，session id的值应该是一个既不会</p>
<p>重复，又不容易被找到规律以仿造的字符串，这个session id将被在本次响应中返回给客户端保存。保存这个session id的方式可以采cookie这</p>
<p>样在交互过程中浏览器可以自动的按照规则把这个标识发送给服务器。一般这个cookie的名字都是类似于SEEESIONID。但cookie可以被人为的</p>
<p>禁止，则必须有其他机制以便在cookie被禁止时仍然能够把session id传递回服务器及URL重写-把session id以参数的形式添加得到URL中。</p>
<h2 id="session和cookie实现登录退出"><a href="#session和cookie实现登录退出" class="headerlink" title="session和cookie实现登录退出"></a>session和cookie实现登录退出</h2><p>后台代码登录时会生成一个session id保存在cookie中</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div></pre></td><td class="code"><pre><div class="line"><span class="comment">// 实现登录功能</span></div><div class="line">$(<span class="string">'#loginBtn'</span>).on(<span class="string">'click'</span>, <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</div><div class="line">       $.ajax(&#123;</div><div class="line">           type: <span class="string">'post'</span>,</div><div class="line">           url: <span class="string">'/api/login'</span>,</div><div class="line">           data: $(<span class="string">'#loginForm'</span>).serialize(),</div><div class="line">           dataType: <span class="string">'json'</span>,</div><div class="line">           success: <span class="function"><span class="keyword">function</span>(<span class="params">data</span>) </span>&#123;</div><div class="line">               <span class="keyword">if</span> (data.code == <span class="number">200</span>) &#123;</div><div class="line">                   location.href = <span class="string">'/main/index'</span>;</div><div class="line">                   <span class="comment">//登录成功把个人信息传递给cookie并且命名为loginInfo</span></div><div class="line">                   $.cookie(<span class="string">'loginInfo'</span>, <span class="built_in">JSON</span>.stringify(data.result), &#123; <span class="attr">path</span>: <span class="string">'/'</span> &#125;);</div><div class="line">               &#125;</div><div class="line">           &#125;</div><div class="line">       &#125;)</div><div class="line">       <span class="keyword">return</span> <span class="literal">false</span>;</div><div class="line">   &#125;)</div><div class="line"></div><div class="line"><span class="comment">//渲染个人信息</span></div><div class="line">   <span class="comment">//必须引用jquery-cookie.js</span></div><div class="line">   <span class="comment">//把缓存数据转化为对象</span></div><div class="line"><span class="comment">//缓存的数据包含个人信息</span></div><div class="line">   <span class="keyword">var</span> loginInfo = $.cookie(<span class="string">'loginInfo'</span>);</div><div class="line">   loginInfo = loginInfo &amp;&amp; <span class="built_in">JSON</span>.parse(loginInfo);</div><div class="line"><span class="comment">//通过artTemplate.js把信息渲染到页面</span></div><div class="line">   <span class="keyword">var</span> tpl = <span class="string">'&lt;div class="avatar img-circle"&gt;&lt;img src="&#123;&#123;tc_avatar&#125;&#125;"&gt;&lt;/div&gt;&lt;h4&gt;&#123;&#123;tc_name&#125;&#125;&lt;/h4&gt;'</span>;</div><div class="line">   <span class="keyword">var</span> html = template.render(tpl, loginInfo);</div><div class="line">   $(<span class="string">'.aside .profile'</span>).html(html);</div></pre></td></tr></table></figure>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="comment">//退出</span></div><div class="line">   $(<span class="string">'#logoutBtn'</span>).on(<span class="string">'click'</span>, <span class="function"><span class="keyword">function</span>(<span class="params"></span>) </span>&#123;</div><div class="line">       $.ajax(&#123;</div><div class="line">           type: <span class="string">'post'</span>,</div><div class="line">           url: <span class="string">'/api/logout'</span>,</div><div class="line">           dataType: <span class="string">'json'</span>,</div><div class="line">           success: <span class="function"><span class="keyword">function</span>(<span class="params">data</span>) </span>&#123;</div><div class="line">               <span class="keyword">if</span> (data.code == <span class="number">200</span>) &#123;</div><div class="line">                   location.href = <span class="string">'/main/login'</span>;</div><div class="line">                   $.removeCookie(<span class="string">'PHPSESSID'</span>); <span class="comment">//退出时移除cookie中的PHPSESSID(session id)</span></div><div class="line">               &#125;</div><div class="line">           &#125;</div><div class="line">       &#125;)</div><div class="line">   &#125;);</div></pre></td></tr></table></figure>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2017/09/13/canvas/" rel="next" title="canvas">
                <i class="fa fa-chevron-left"></i> canvas
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2017/09/20/require.js的使用方法和sea.js/" rel="prev" title="Javascript模块化编程require.js的用法和sea.js">
                Javascript模块化编程require.js的用法和sea.js <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://dynamic-image.yesky.com/300x-/uploadImages/upload/20140912/upload/201409/wylnwjynkxijpg.jpg"
               alt="shine-wl" />
          <p class="site-author-name" itemprop="name">shine-wl</p>
           
              <p class="site-description motion-element" itemprop="description"></p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
            
              <a href="/archives/">
            
                <span class="site-state-item-count">21</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          

          
            
            
            <div class="site-state-item site-state-tags">
              
                <span class="site-state-item-count">15</span>
                <span class="site-state-item-name">标签</span>
              
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#javascript操作cookie的方法"><span class="nav-number">1.</span> <span class="nav-text">javascript操作cookie的方法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#jquery操作cookie的方法"><span class="nav-number">2.</span> <span class="nav-text">jquery操作cookie的方法</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#session"><span class="nav-number">3.</span> <span class="nav-text">session</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#session与cookie的关系"><span class="nav-number">4.</span> <span class="nav-text">session与cookie的关系</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#session和cookie实现登录退出"><span class="nav-number">5.</span> <span class="nav-text">session和cookie实现登录退出</span></a></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">shine-wl</span>

  
</div>


  <div class="powered-by">由 <a class="theme-link" href="https://hexo.io">Hexo</a> 强力驱动</div>

  <span class="post-meta-divider">|</span>

  <div class="theme-info">主题 &mdash; <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next">NexT.Gemini</a> v5.1.2</div>


        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.1.2"></script>



  
  


  <script type="text/javascript" src="/js/src/affix.js?v=5.1.2"></script>

  <script type="text/javascript" src="/js/src/schemes/pisces.js?v=5.1.2"></script>



  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  








  





  

  

  

  

  

  

</body>
</html>
